int ** vs int [ROWS][COLS]
Posted
by user355638
on Stack Overflow
See other posts from Stack Overflow
or by user355638
Published on 2010-06-01T16:37:00Z
Indexed on
2010/06/01
16:43 UTC
Read the original article
Hit count: 162
I have a 2D array declared like this:
int arr[2][2]={ {1,2},{3,4}};
Now if I do:
int ** ptr=(int**) arr;
and:
cout<<**ptr;
I am getting a segmentation fault (using g++-4.0).
Why so? Shouldn't it be printing the value 1 (equal to arr[0][0]
)?
© Stack Overflow or respective owner